package cn.promptness.rpt.server.maxmind;

import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbParameter;

public final class CountryResponse {

    private final Country country;

    public Country getCountry() {
        return country;
    }

    @MaxMindDbConstructor
    public CountryResponse(@MaxMindDbParameter(name = "country") Country country) {
        this.country = country;
    }

    public static class Country {

        private final Integer confidence;
        private final boolean isInEuropeanUnion;
        private final String isoCode;

        @MaxMindDbConstructor
        public Country(@MaxMindDbParameter(name = "confidence") Integer confidence, @MaxMindDbParameter(name = "is_in_european_union") Boolean isInEuropeanUnion, @MaxMindDbParameter(name = "iso_code") String isoCode) {
            this.confidence = confidence;
            this.isInEuropeanUnion = isInEuropeanUnion != null && isInEuropeanUnion;
            this.isoCode = isoCode;
        }

        public Integer getConfidence() {
            return confidence;
        }

        public boolean isInEuropeanUnion() {
            return isInEuropeanUnion;
        }

        public String getIsoCode() {
            return isoCode;
        }
    }
}
